In recent years, programming languages that allow exception handling to be described has become widely used for the purpose of improving maintainability and robustness of programs. When an exception is thrown in a program written in such a programming language, the program shifts its processing from the point in the program where the exception has been thrown to an exception handler that handles the exception. For optimizing the shift of processing to an exception handler, a technology has been utilized that detects types of frequently thrown exceptions and rewrites the instruction that can throw the detected types of exception to a branch instruction leading to an exception handler. See the document, by Takeshi Ogasawara, Hideaki Komatsu, and Toshio Nakatani, “A study of Exception Handling and Its Dynamic Optimization in Java(registered trademark)”, Object-Oriented Programming Systems, Languages, and Applications (OOPSLA2001) proceeding, 2001.
The technology described above, however, cannot optimize shift of processing to an exception handler if the types of exception that are to be thrown cannot be determined. For example, if an exception handler for catching multiple types of exception rethrows an exception it has caught, a compiler apparatus cannot determine how to optimize the instruction for rethrowing the exception since it cannot decide in advance which type of exception to catch.